const logout = document.querySelector('.logout')
// 获取一级标题元素
const oneAList = document.querySelectorAll('.nav>li>a')
// 获取二级标题元素
const subAList = document.querySelectorAll(".nav ul a")
//退出登陆点击事件
logout.addEventListener('click', function (e) {

    //弹出确认框
    if (confirm('您确定退出吗？')) {
        localStorage.removeItem('token8788')
        //跳转
        location.href = 'login.html'
    }
})
// 给一级菜单绑定点击事件
oneAList.forEach((one) => {
    one.addEventListener('click', function (e) {
        // one.nextElementSibling.classList.toggle('show')

        $(one).next().toggle(1000)
    })
});

// 给二级菜单绑定点击事件
subAList.forEach((sub) => {
    sub.addEventListener('click', function (e) {
        // 获取以前选中的a标签
        const beForeA = document.querySelector('.nav ul a.active')
        //移除类
        beForeA.classList.remove('active')
        //当前添加
        sub.classList.add('active')
    })
})

